// main.ts
import { createSSRApp } from 'vue'
import App from './App.vue'
import TnIcon from '@tuniao/tnui-vue3-uniapp/components/icon/src/icon.vue'
import ListItem from '@tuniao/tnui-vue3-uniapp/components/list/src/list-item.vue'
import store from './store'

// 延迟导入 mixin，确保 store 已创建
import { createGlobalMixin } from './store/$t.mixin.js'
export function createApp() {
  const app = createSSRApp(App)

  app.component('TnIcon', TnIcon)
  app.use(store)
  // ✅ 等 store 创建后，再注册 mixin
  const globalMixin = createGlobalMixin(store)
  app.mixin(globalMixin)

  return {
    app,
    store
  }
}